YZYZ.Admin.Attractions.editForm		= null;
YZYZ.Admin.Attractions.editWin		= null;
YZYZ.Admin.Attractions.showEditWin=function(id){
	if(!YZYZ.Admin.Attractions.editWin){
		YZYZ.Admin.Attractions.editForm=new Ext.form.FormPanel({
			width:600,
			height:400,
			region:'center',
			labelWidth:80,
			labelAlign:'right',
			bodyStyle:'padding:10px;',
			items:[{
				xtype:'textfield',
				width:400,
				fieldLabel:'名称',
				id:'editAttName',
				maxLength:100
			},{
				xtype:'htmleditor',
				width:500,
				height:250,
				fieldLabel:'描述',
				id:'editAttDes',
				maxLength:2000
			}]
		});
		YZYZ.Admin.Attractions.editWin=new Ext.Window({
			layout:'border',
			title:'添加景点',
			closable:true,
			width:650,
			height:400,
			closeAction:'hide',
			modal:true,
			items:[YZYZ.Admin.Attractions.editForm],
			buttons:[{
				text:'提交',
				width:60,
				handler:YZYZ.Admin.Attractions.submitEditAtt
			},{
				text:'关闭',
				width:60,
				handler:function(){YZYZ.Admin.Attractions.editWin.hide()}
			}]
		})
	}
	YZYZ.Admin.Attractions.editWin.show();
	var rec = YZYZ.Admin.Attractions.gridPanel.getSelectionModel().getSelected();
	Ext.getCmp("editAttName").setValue(rec.get("name"));
	Ext.getCmp("editAttDes").setValue(rec.get("description"));
};
YZYZ.Admin.Attractions.submitEditAtt=function(){
	var name 	= Ext.getCmp("editAttName").getValue();
	var des 	= Ext.getCmp("editAttDes").getValue();
	if(Ext.isEmpty(name)){
		YZYZ.Curtain.alert("名称不能为空"),
		Ext.getCmp("editAttName").markInvalid();
		return;
	}
	if(name.length > 100){
		YZYZ.Curtain.alert("名称长度不能超过100"),
		Ext.getCmp("editAttName").markInvalid();
		return;
	}
	if(Ext.isEmpty(name)){
		YZYZ.Curtain.alert("描述不能为空"),
		Ext.getCmp("editAttDes").markInvalid();
		return;
	}
	if(des.length > 2000){
		YZYZ.Curtain.alert("描述长度不能超过2000"),
		Ext.getCmp("editAttDes").markInvalid();
		return;
	}
	YZYZ.Curtain.msg("系统处理中....");
	Ext.Ajax.request( {
		url		: Ext.get("editAttUrl").dom.value,
		timeout	: 30000,
		method	: 'POST',
		params	: {
			name 		: name,
			description	: des,
			attId 		: YZYZ.Admin.Attractions.gridPanel.getSelectionModel().getSelected().get("id")
		},
		success : function(result, request) {
			result = Ext.util.JSON.decode(result.responseText);
			if(result.code == YZYZ.success){
				YZYZ.Curtain.msg("修改成功");
				var rec=YZYZ.Admin.Attractions.gridPanel.getSelectionModel().getSelected();
				rec.set("name",name);
				rec.set("description",des);
				YZYZ.Admin.Attractions.gridPanel.getStore().commitChanges();
				YZYZ.Admin.Attractions.editWin.hide();			
			}
			else {
				YZYZ.Curtain.alert(result.message);
			}
		},
		failure : function(result, request) {
			YZYZ.Curtain.alert("操作失败！程序错误或网络故障");
		}
	});
};